﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CrankShaftAnalysisSystem
{
    public partial class FormPlacePart : Form
    {
        PLCMaster PLC;
        public event Action OnStepConfirmed;
        public FormPlacePart()
        {
            InitializeComponent();
            PLC = PLCMaster.Instance;
        }

        private void btnConfirmUuid_Click(object sender, EventArgs e)
        {
            if(ledManulOn.On && ledPartOK.On)
            {
                if(OnStepConfirmed != null)
                {
                    OnStepConfirmed();
                }
            }

        }

        private void FormPlacePart_Load(object sender, EventArgs e)
        {
            tmLoop.Start();
            UIHelper.SetPanelToCenter(ref panelMain);
        }

        private void tmLoop_Tick(object sender, EventArgs e)
        {
            ledManulOn.On = Tools.GetBitState(PLC.Device.Info.ButtonInfo, VirtualDevice.Mask.MANUALON);
            ledPartOK.On = Tools.GetBitState(PLC.Device.Info.FeedBackInfo, VirtualDevice.Mask.PARTEXIST);
        }
    }
}
